import axios from "axios";

interface DataState {
  pageSize: number
  pageCode: number
}

export const fetchList = (params: DataState) => {
  return async (dispatch: any) => {
    const resp = await axios.get("/api/list", { params: params });
    const { code, message, data } = resp.data;
    if(code === 200) {
      dispatch({ type: "setList", payload: resp.data.data });
      dispatch({ type: 'addPageCode' })
    } else {
      dispatch({ type: 'setFinish', payload: true })
    }
  
  };
};


// dispatch({ type, payload })

// dispatch(() => {
//   return (dispatch) => {
//     dispatch({ type, payload })
//     dispatch(() => {
      
//     })
//   }
// })
